package com.wao.cms.service.mapper;

import com.wao.cms.domain.*;
import com.wao.cms.service.dto.PageDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity Page and its DTO PageDTO.
 */
@Mapper(componentModel = "spring", uses = {WebsiteMapper.class, TemplateMapper.class, })
public interface PageMapper extends EntityMapper <PageDTO, Page> {

    @Mapping(source = "website.id", target = "websiteId")
    @Mapping(source = "website.name", target = "websiteName")

    @Mapping(source = "template.id", target = "templateId")
    @Mapping(source = "template.name", target = "templateName")
    PageDTO toDto(Page page); 

    @Mapping(source = "websiteId", target = "website")

    @Mapping(source = "templateId", target = "template")
    Page toEntity(PageDTO pageDTO); 
    default Page fromId(Long id) {
        if (id == null) {
            return null;
        }
        Page page = new Page();
        page.setId(id);
        return page;
    }
}
